// components/OrderStatusTag.tsx
import React from 'react';
import { Tag } from 'antd';
import { orderStatusEnum, StatusColors } from './colors';

interface OrderStatusTagProps {
  statusCode: keyof typeof orderStatusEnum | string;
  showIcon?: boolean;
}

const OrderStatusTag: React.FC<OrderStatusTagProps> = ({ 
  statusCode, 
  showIcon = true 
}) => {
  const statusConfig = orderStatusEnum[statusCode as keyof typeof orderStatusEnum] || {
    text: `未知状态(${statusCode})`,
    color: StatusColors.DEFAULT,
    status: 'default',
  };

  return (
    <Tag
      color={statusConfig.color}
      icon={showIcon ? statusConfig.icon : null}
      style={{
        fontWeight: 600,
        borderRadius: 12,
        padding: '0 8px',
        margin: 0,
        border: `1px solid ${statusConfig.color}`,
      }}
    >
      {statusConfig.text}
    </Tag>
  );
};

export default OrderStatusTag;